package com.xuqi.W3;

public class W3Response {
	private int			m_iErrorCode;			// error code
	private int			m_iResponseCode;		// response code
	private String		m_szHeaderFields;		// response header fields
	private boolean		m_bSaveToFile;			// true: file ; false: binary data
	private int			m_iResponseSize;		// count of bytes received from server
	private String		m_szResponseFileName;	// path to the file received from server
	private byte[]		m_byResponseData;		// binary data received from server
	
	/**
	 * Constructor
	 */
	public W3Response() {
		m_iErrorCode = 0;
		m_iResponseCode = -1;
		m_szHeaderFields = "";
		m_bSaveToFile = false;
		m_iResponseSize = 0;
		m_szResponseFileName = "";
		m_byResponseData = null;
	}

	/**
	 * Get error code of the response.
	 */
	public int getErrorCode() {
		return m_iErrorCode;
	}

	/**
	 * Get HTTP status code returned from server.
	 */
	public int getResponseCode() {
		return m_iResponseCode;
	}

	/**
	 * Get header fields returned from server.
	 */
	public String getHeaderFields() {
		return m_szHeaderFields;
	}

	/**
	 * Get count of bytes received from server.
	 */
	public int getResponseSize() {
		return m_iResponseSize;
	}

	/**
	 * Get if received data is saved to file.
	 */
	public boolean isSaveToFile() {
		return m_bSaveToFile;
	}

	/**
	 * Get path of the received file, valid only if [isSaveToFile] returns true.
	 */
	public String getResponseFileName() {
		return m_szResponseFileName;
	}

	/**
	 * Get data received from server, valid only if [isSaveToFile] returns false.
	 */
	public byte[] getResponseData() {
		return m_byResponseData;
	}

	/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
	 *	protected functions, not for public usage.
	 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/

	protected void setErrorCode(int iErrorCode) {
		m_iErrorCode = iErrorCode;
	}

	protected void setResponseCode(int iResponseCode) {
		m_iResponseCode = iResponseCode;
	}

	protected void setHeaderFields(String szHeaderFields) {
		m_szHeaderFields = szHeaderFields;
	}

	protected void setSaveToFile(boolean bSaveToFile) {
		m_bSaveToFile = bSaveToFile;
	}

	protected void setResponseSize(int iDataSize) {
		m_iResponseSize = iDataSize;
	}

	protected void setResponseFileName(String szFileName) {
		m_szResponseFileName = szFileName;
	}

	protected void setResponseData(byte[] byResponseData) {
		m_byResponseData = byResponseData;
	}
}
